Skip to content

[WIP] Sparse implementation of EMD#683

Closed
tvayer wants to merge 6 commits intoPythonOT:masterfrom
tvayer:emd_sparse_implem
Closed

[WIP] Sparse implementation of EMD#683
tvayer wants to merge 6 commits intoPythonOT:masterfrom
tvayer:emd_sparse_implem

Conversation

@tvayer
Copy link
Copy Markdown
Collaborator

@tvayer tvayer commented Oct 31, 2024

The goal is to return a sparse transport in ot.emd plan when the cost matrix matrix is itself sparse which corresponds to infinite cost between points, or when no value is given i.e. we know that no match is allowed.

Wishlist

  • Accelerate the EMD when the cost is sparse
  • Stay in O(nnz(C)) in memory

What we have

  • Working cython wrapper for coo cost matrix, it returns the same result at numerical precision

Working example:

from ot.lp import emd_wrap

# COO representation of cost
iM2 = sM2.row
jM2 = sM2.col
vM2 = sM2.data

maxitr= 1000000
g,ig,jg, cost, alpha, beta, result_code = emd_wrap.emd_c_sparse(a,b,iM2,jM2,vM2, np.int64(maxitr))

# recover the sparse plan
Gs = sp.sparse.coo_matrix((g, (ig, jg)), shape=(m,n))

What we want

  • Change the cpp of NetworkSimplex to remove the O(n^2) memory when associating the cost to each edge of the network flow

@github-actions github-actions Bot added the ot.lp label Dec 17, 2024
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 17, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.06%. Comparing base (39cd6ec) to head (ba81674).
⚠️ Report is 50 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #683   +/-   ##
=======================================
  Coverage   97.06%   97.06%           
=======================================
  Files          98       98           
  Lines       19955    19955           
=======================================
  Hits        19370    19370           
  Misses        585      585           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rflamary
Copy link
Copy Markdown
Collaborator

This has been done by @nathanneike thanks @tvayer for the work but 'im closing the PR

@rflamary rflamary closed this Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants